package com.jinxin.platform.cdinfogo.service.impl;

import com.jinxin.platform.cdinfogo.pojo.domain.CdinfogoDc;
import com.jinxin.platform.cdinfogo.mapper.CdinfogoDcMapper;
import com.jinxin.platform.cdinfogo.service.CdinfogoDcService;
import org.springframework.stereotype.Service;
import com.jinxin.platform.base.common.pojo.JsonResult;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CdinfogoDc)表服务实现类
 *
 * @author zhangpeng
 * @since 2021-06-28 17:23:35
 */
@Service("cdinfogoDcService")
public class CdinfogoDcServiceImpl implements CdinfogoDcService {
    @Resource
    private CdinfogoDcMapper cdinfogoDcMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JsonResult queryById(String id) {
        CdinfogoDc cdinfogoDc = this.cdinfogoDcMapper.queryById(id);
        return JsonResult.ok(cdinfogoDc);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param cdinfogoDc 实例对象
     * @return 对象列表
     */
    @Override
    public JsonResult queryAll(CdinfogoDc cdinfogoDc) {
        List<CdinfogoDc> cdinfogoDcList =  this.cdinfogoDcMapper.queryAll(cdinfogoDc);
        return JsonResult.ok(cdinfogoDcList);
    }

    /**
     * 新增数据
     *
     * @param cdinfogoDc 实例对象
     * @return 实例对象
     */
    @Override
    public JsonResult insert(CdinfogoDc cdinfogoDc) {
        int i = this.cdinfogoDcMapper.insert(cdinfogoDc);
        return i > 0 ? JsonResult.ok("新增成功",cdinfogoDc) : JsonResult.error("新增失败！");
    }

    /**
     * 修改数据
     *
     * @param cdinfogoDc 实例对象
     * @return 实例对象
     */
    @Override
    public JsonResult update(CdinfogoDc cdinfogoDc) {
        int i = this.cdinfogoDcMapper.update(cdinfogoDc);
        return i > 0 ? JsonResult.ok("修改成功！",null) : JsonResult.error("修改失败！");
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public JsonResult deleteById(String id) {
        return this.cdinfogoDcMapper.deleteById(id) > 0 ? JsonResult.ok("删除成功！",null) : JsonResult.error("删除失败！");
    }
}